1. Field of the Invention
The present invention relates to an image processing method and apparatus for computing a position from a reference point or an inclination from a reference line as a condition in which a workpiece is disposed using not only data concerning a workpiece image picked up for the purpose of detecting the position of the workpiece as an object for detection but also pre-cataloged data concerning the workpiece image.
2. Description of the Related Art
FIGS. 41A and 41B are schematic block diagrams illustrating a conventional image processing apparatus. The conventional image processing apparatus comprises a central processing unit (hereinafter referred to as "CPU") 1a for performing control and arithmetic processes in the entire apparatus, an imaging device 2 for optically fetching a workpiece image, a storage device 3a for storing operational program data for the CPU la and results of operations, a display unit 4 for graphically displaying a position where a workpiece is detected on the basis of the results of operations performed by the CPU 1a, an input device 5 for feeding input data and command data to the CPU 1a, an output device 6 for outputting the contents displayed on the display unit 4 in the form of characters and the like, a communication device 7 for transferring the detected position data to other devices, an image fetch means 301 for fetching the image stored in the storage device 3a, a workpiece image data cataloging means 302a for cataloging image data on a workpiece as an object whose position and tilted angle are to be detected, a rotated workpiece image generating means 341 for generating an image t0a1-t0a359 resulting from rotating the workpiece out of cataloged workpiece image data t0a so as to detect its tilted angle, and a correlation value computing means 306a for computing the correlation value between the workpiece image data t0a and image data v1 fetched from the imaging device 2 to detect the position of the workpiece together with its tilted angle.
A description will subsequently be given of a method of cataloging the image of a workpiece w0 so as to detect the position of the workpiece and its tilted angle as shown in FIGS. 43A and 43B by means of the conventional image processing apparatus thus configured by reference to a flowchart of FIG. 42, diagrams of FIGS. 43A and 43B in a workpiece imaging mode, diagrams of FIGS. 44A and 44B in a workpiece image data mode, diagrams of FIGS. 45A and 45B in a rotated workpiece image data mode, diagrams of FIGS. 46A and 46B in a fetched image data imaging mode, and diagrams of FIGS. 47A and 47B in a mode of detecting the position-tilted angle of the workpiece. In order to distinguish visual displays on the display unit in the drawings above from those illustrative of internal processing in an easy-to-understand way, reference characters starting with v such as v0, v1 will be employed as those representing visual displays of FIGS. 43B, 47A, 47B and so forth.
At Step S501 of FIG. 42, first, a workpiece image data creation command is input by the input device 5 of FIG. 41A (workpiece image data creation command).
At Step S502 then, the CPU 1a starts the image fetch means 301 of the storage device 3a to fetch an image of the workpiece w0 shown in FIG. 43A from the imaging device 2 (fetching of image).
At Step S503, further, the CPU 1a displays on the display unit 4 the image data v0 shown in FIG. 43B (display of fetched image).
At Step S504, further, a workpiece image data size.multidot.position setting command is input by the input device 5 to make the CPU 1a display on the display unit 4 a rectangular window frame c0a of FIG. 44A in which the size.multidot.position of the workpiece image data are shown. Then the CPU 1a is made to extract pixel data within the frame c0a by inputting the size.multidot.position data on the workpiece image data, changing the frame c0a into the input size and moving it to the input position and to generate the pixel data as the workpiece image data t0a shown in FIG. 44B (designation of size.multidot.position of workpiece image data). In FIG. 44B, workpiece image data T0a represents the structure of the workpiece image data t0a and the workpiece image data T0a is configured in the form of grid-spaced luminance data. Numerical values 1, 5, 7, . . . denote the luminance of the workpiece image data.
At Step S505, the CPU la starts the rotated workpiece image generating means 341 and turns the workpiece image data t0a, degree by degree, up to 359.degree. to generate the rotated workpiece image data ranging from t0a1 up to t0a359 as shown in FIG. 45A (rotated workpiece image generation). In FIG. 45B, moreover, the rotated workpiece image data TOa20 represents the structure of the rotated workpiece image data TOa20 resulting from turning the workpiece image data t0a through an angle of 20.degree.. The rotated workpiece image data T0a20 is such that luminance data on the workpiece image data t0a is turned through an angle of 20.degree. and stored in a grid-spaced arrangement. The other rotated workpiece image data ranging from t0a1 up to t0a19 and those ranging from t0a21 up to t0a359 are turned degree by degree and stored in the grid-spaced arrangement likewise.
At Step S506, the CPU 1a starts the workpiece image data cataloging means 302a of the storage device 3a and stores in the storage device 3a the workpiece image data t0a and the rotated workpiece image data t0a1-t0a359 (cataloging of workpiece image data).
At Step S507, a position.multidot.tilted angle detection command and the threshold value s0a of the correlation value sa between the workpiece image data t0a and the fetched image data are input by the input device 5 of FIG. 41A (position.multidot.tilted angle detection command). In this case, the threshold value s0a of the correlation value is set so that only a greater correlation value is detected: for example, 90% of the maximum value of the correlation value sa that can be taken.
At Step S508, further, the CPU 1a terminates the processing when it is interrupted by a termination command (reception of termination command).
In the absence of the termination command at Step S509, the CPU 1a starts the image fetch means 301 of the storage device 3a and has a workpiece w1 of FIG. 46A picked up by the imaging device 2 in order that the image data v1 shown in FIG. 46B may be displayed on the display unit 4 (fetching of image). In this case, the workpiece w1 is tilted by an angle of "a" and placed within the visual field of the imaging device 2.
At Step S510, the CPU 1a superimposes the workpiece image data t0a and the fetched image data v1, starts the correlation value computing means 306a of the storage device 3a and then computes the correlation value sa between the workpiece image data t0a and the fetched image data v1 using the following correlation equation (1) based on normal correlation (correlation value computation). ##EQU1##
Where the symbol Fi represents the luminance value of the i-th pixel of the workpiece image data t0a; Gi, the luminance value of the i-th subscript of the fetched image data vi; n, the number of pixels of workpiece image data; and the subscript i, a pixel number.
At Step S511, the CPU 1a decides that when the correlation value sa is greater than the threshold value s0a, the workpiece image data t0a correlates with the fetched image data v1. FIG. 47B shows that the luminance of workpiece image data T0a 35 appears to conform to workpiece image data t0a 35 on the fetched image data v1. FIG. 47A refers to a case where workpiece image data TOa20, for example, is situated in a position in nonconformity with the position of the workpiece w1 on the fetched image v1, whereby the luminance of the workpiece image data remains in nonconformity with the workpiece image data (correlation exists).
At Step S512, the CPU 1a displays the position.multidot.tilted angle on the display unit 4 when the correlation is judged existent at Step S511 and sends the position.multidot.tilted angle to the communication device 7 (outputting of position.multidot.tilted angle).
At Step S513, further, the CPU 1a decides whether to have completed the computation of the correlation value sa over the whole fetched image data v1 when the correlation is judged nonexistent, shifts the position of a pixel one place where the workpiece image data t0a and the fetched image data v1 are to be superimposed when the CPU 1a decides to have not completed the computation and repeats the steps from S510 up to S513 (completion of the whole pixel computation).
At Step S514, the CPU 1a updates the rotated workpiece image data to what has an tilted angle greater by one degree when it is decided that the computation at Step S513 has been completed. For example, rotated image data t0a1 is updated to rotated image data t0a1 whose tilted angle is greater than the former data by one degree (update to the next workpiece image data).
At Step S515, further, the CPU 1a regards the process of detecting the position.multidot.tilted angle of the whole rotated workpiece image data as being completed and completes the processing of the workpiece w1 when rotated workpiece image data to be updated is the rotated workpiece image data t0a359 at Step S514. At Step S508, the CPU 1a alters the position.multidot.tilted angle of the workpiece w1 or replaces the workpiece w1 with another one similar in configuration until receiving the termination command and repeats the steps from S509 up to S515 (completion of processing the whole rotated workpiece image data).
Since the conventional image processing apparatus is configured as described above, the problem is that when a workpiece is turned degree by degree up to 360.degree., the time required to create image data at every angle and to compute the correlation value in order to detect the tilted angle of the workpiece tends to become longer.